package com.yanghui.agent.plugin;

import com.yanghui.agent.agentBytebuddy.plugin.IMethodInterceptor;
import redis.clients.jedis.Jedis;

public class JedisMethodInterceptor implements IMethodInterceptor {
    @Override
    public Object before(Object thisObj) {
        Long start = System.currentTimeMillis();
        try{
            Jedis jedis = (Jedis) thisObj;
            System.out.println(jedis.info());
        }catch (Throwable t){
            t.printStackTrace();
        }
        return start;
    }

    @Override
    public void after(Object params) {
        Long end = System.currentTimeMillis();
        Long start = (Long)params;
        System.out.println("耗时：" + (end - start) + "毫秒");
    }
}
